package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/4 11:08
 * @description
 */
public class Code941 {
    public static void main(String[] args) {
        System.out.println(new Code941().validMountainArray(
            new int[] {14, 82, 89, 84, 79, 70, 70, 68, 67, 66, 63, 60, 58, 54, 44, 43, 32, 28, 26, 25, 22, 15, 13, 12,
                10, 8, 7, 5, 4, 3}));
    }

    public boolean validMountainArray(int[] A) {
        if (A.length < 3 || A[1] < A[0]) {
            return false;
        }
        boolean flag = true;
        for (int i = 0; i < A.length - 1; i++) {
            if (flag) {
                if (A[i + 1] == A[i]) {
                    return false;
                }
                if (A[i + 1] - A[i] < 0) {
                    flag = false;
                }
            } else {
                if (A[i + 1] - A[i] >= 0) {
                    return false;
                }
            }
        }
        if (flag) {
            return false;
        }
        return true;
    }
}
